// 格式化时间
let formatDate = function formatDate(date, format) {
    let o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds(),
        'q+': Math.floor((date.getMonth() + 3) / 3),
        'S': date.getMilliseconds()
    }
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
    }
    for (let k in o) {
        if (new RegExp('(' + k + ')').test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
        }
    }
    return format
}
// long转时间
let formatDateFromLong = (timestamp, format) => {
    let date = null
    if (!timestamp) {
        return '无'
    }
    try {
        date = formatDate(new Date(timestamp), format)
    } catch (e) {
        return '无'
    }
    return date
}

function generateUUID() {
    let s = []
    let hexDigital = '0123456789abcdef'
    for (let i = 0; i < 36; i++) {
        s[i] = hexDigital.substr(Math.floor(Math.random() * 0X10), 1)
    }
    s[14] = '4'
    s[19] = hexDigital.substr((s[19] & 0X3) | 0X8, 1)
    s[8] = s[13] = s[18] = s[23] = '-'
    return s.join('')
}

function cronValidate(cronExpression) {
    if (!cronExpression || /^\s+$/.test(cronExpression)) return '表达式不能为空!'
    // 返回错误信息用
    let message = ''
    // 先将cron表达式进行分割
    let cronParams = cronExpression.split(' ')
    // 判断cron表达式是否具有该具有的属性长度，没有年份的长度为6，带年份的长度为7，其他情况都是错误的
    if (cronParams.length < 6 || cronParams.length > 7) {
        return 'cron表达式需要输入6-7位参数，请重新输入'
    } else {
        // 日和周必须有一个为?，或者全为*
        if ((cronParams[3] === '?' && cronParams[5] !== '?') || (cronParams[5] === '?' && cronParams[3] !== '?') || (cronParams[3] === '*' && cronParams[5] === '*')) {
            // 检查第一位的秒是否正确
            message = checkSecondsField(cronParams[0])
            if (message !== true) {
                return message
            }

            // 检查第二位的分是否正确
            message = checkMinutesField(cronParams[1])
            if (message !== true) {
                return message
            }

            // 检查第三位的时是否正确
            message = checkHoursField(cronParams[2])
            if (message !== true) {
                return message
            }

            // 检查第四位的日是否正确
            message = checkDayOfMonthField(cronParams[3])
            if (message !== true) {
                return message
            }

            // 检查第五位的月是否正确
            message = checkMonthsField(cronParams[4])
            if (message !== true) {
                return message
            }

            // 检查第6位的周是否正确
            message = checkDayOfWeekField(cronParams[5])
            if (message !== true) {
                return message
            }

            // 检查第七位的年是否正确
            if (cronParams.length > 6) {
                message = checkYearField(cronParams[6])
                if (message !== true) {
                    return message
                }
            }

            return true
        } else {
            return '指定日时周必须设为不指定(?),指定周时日必须设为不指定(?)'
        }
    }
}

// 检查秒的函数方法
function checkSecondsField(secondsField) {
    return checkField(secondsField, 0, 59, '秒')
}

// 检查分的函数方法
function checkMinutesField(minutesField) {
    return checkField(minutesField, 0, 59, '分')
}

// 检查小时的函数方法
function checkHoursField(hoursField) {
    return checkField(hoursField, 0, 23, '时')
}

// 检查日期的函数方法
function checkDayOfMonthField(dayOfMonthField) {
    if (dayOfMonthField === '?') {
        return true
    }
    if (dayOfMonthField.indexOf('L') >= 0) {
        return checkFieldWithLetter(dayOfMonthField, 'L', 1, 7, '日')
    } else if (dayOfMonthField.indexOf('W') >= 0) {
        return checkFieldWithLetter(dayOfMonthField, 'W', 1, 31, '日')
    } else if (dayOfMonthField.indexOf('C') >= 0) {
        return checkFieldWithLetter(dayOfMonthField, 'C', 1, 31, '日')
    }
    return checkField(dayOfMonthField, 1, 31, '日')
}

// 检查月份的函数方法
function checkMonthsField(monthsField) {
    // 月份简写处理
    if (monthsField !== '*') {
        monthsField = monthsField.replace('JAN', '1')
        monthsField = monthsField.replace('FEB', '2')
        monthsField = monthsField.replace('MAR', '3')
        monthsField = monthsField.replace('APR', '4')
        monthsField = monthsField.replace('MAY', '5')
        monthsField = monthsField.replace('JUN', '6')
        monthsField = monthsField.replace('JUL', '7')
        monthsField = monthsField.replace('AUG', '8')
        monthsField = monthsField.replace('SEP', '9')
        monthsField = monthsField.replace('OCT', '10')
        monthsField = monthsField.replace('NOV', '11')
        monthsField = monthsField.replace('DEC', '12')
        return checkField(monthsField, 1, 12, '月份')
    } else {
        return true
    }
}

// 星期验证
function checkDayOfWeekField(dayOfWeekField) {
    dayOfWeekField = dayOfWeekField.replace('SUN', '1')
    dayOfWeekField = dayOfWeekField.replace('MON', '2')
    dayOfWeekField = dayOfWeekField.replace('TUE', '3')
    dayOfWeekField = dayOfWeekField.replace('WED', '4')
    dayOfWeekField = dayOfWeekField.replace('THU', '5')
    dayOfWeekField = dayOfWeekField.replace('FRI', '6')
    dayOfWeekField = dayOfWeekField.replace('SAT', '7')
    if (dayOfWeekField === '?') {
        return true
    }
    if (dayOfWeekField.indexOf('L') >= 0) {
        return checkFieldWithLetterWeek(dayOfWeekField, 'L', 1, 7, '星期')
    } else if (dayOfWeekField.indexOf('C') >= 0) {
        return checkFieldWithLetterWeek(dayOfWeekField, 'C', 1, 7, '星期')
    } else if (dayOfWeekField.indexOf('#') >= 0) {
        return checkFieldWithLetterWeek(dayOfWeekField, '#', 1, 7, '星期')
    } else {
        return checkField(dayOfWeekField, 1, 7, '星期')
    }
}

// 检查年份的函数方法
function checkYearField(yearField) {
    return checkField(yearField, 1970, 2099, '年的')
}

// 通用的检查值的大小范围的方法( - , / *)
function checkField(value, minimal, maximal, attribute) {
    // 校验值中是否有“-”，如果有“-”的话，下标会>0
    if (value.indexOf('-') > -1) {
        return checkRangeAndCycle(value, minimal, maximal, attribute)
    }
    // 校验值中是否有“，”，如果有“,”的话，下标会>0
    else if (value.indexOf(',') > -1) {
        return checkListField(value, minimal, maximal, attribute)
    }
    // 校验值中是否有“/”，如果有“/”的话，下标会>0
    else if (value.indexOf('/') > -1) {
        return checkIncrementField(value, minimal, maximal, attribute)
    }
    // 校验值是否为“*”
    else if (value === '*') {
        return true
    }
    // 校验单独的数字，英文字母，以及各种神奇的符号等...
    else {
        return checkIntValue(value, minimal, maximal, true, attribute)
    }
}

// 检测是否是整数以及是否在范围内,参数：检测的值，下限，上限，是否检查端点，检查的属性
function checkIntValue(value, minimal, maximal, checkExtremity, attribute) {
    try {
        // 用10进制犯法来进行整数转换
        let val = parseInt(value, 10)
        if (value - 0 === val) {
            if (checkExtremity) {
                if (val < minimal || val > maximal) {
                    return (attribute + '的参数取值范围必须在' + minimal + '-' + maximal + '之间')
                }
                return true
            }
            return true
        }
        return (attribute + '的参数存在非法字符，必须为整数或允许的大写英文')
    } catch (e) {
        return (attribute + '的参数有非法字符，必须是整数~')
    }
}
// 检验枚举类型的参数是否正确
function checkListField(value, minimal, maximal, attribute) {
    let message
    let st = value.split(',')
    let values = new Array(st.length)
    // 计算枚举的数字在数组中中出现的次数，出现一次为没有重复的。
    let count = 0
    for (let j = 0; j < st.length; j++) {
        values[j] = st[j]
    }
    // 判断枚举类型的值是否重复
    for (let i = 0; i < values.length; i++) {
        // 判断枚举的值是否在范围内
        message = checkIntValue(values[i], minimal, maximal, true, attribute)
        if (message !== true) {
            return message
        }
        count = 0
        for (let j = 0; j < values.length; j++) {
            if (values[i] === values[j]) {
                count++
            }
            if (count > 1) {
                return (attribute + '中的参数重复')
            }
        }
    }
    let previousValue = -1
    // 判断枚举的值是否排序正确
    for (let i = 0; i < values.length; i++) {
        let currentValue = values[i]
        try {
            let val = parseInt(currentValue, 10)
            if (val < previousValue) {
                return (attribute + '的参数应该从小到大')
            } else {
                previousValue = val
            }
        } catch (e) {
            // 前面验证过了，这边的代码不可能跑到
            return ('这段提示用不到')
        }
    }
    return true
}

// 检验循环
function checkIncrementField(value, minimal, maximal, attribute) {
    let message
    if (value.split('/').length > 2) {
        return (attribute + "中的参数只能有一个'/'")
    }
    let start = value.substring(0, value.indexOf('/'))
    let increment = value.substring(value.indexOf('/') + 1)
    if (start !== '*') {
        // 检验前值是否正确
        message = checkIntValue(start, minimal, maximal, true, attribute)
        if (message !== true) {
            return message
        }
        // 检验后值是否正确
        message = checkIntValue(increment, minimal, maximal, true, attribute)
        if (message !== true) {
            return message
        }
        return true
    } else {
        // 检验后值是否正确
        return checkIntValue(increment, minimal, maximal, false, attribute)
    }
}

// 检验范围
function checkRangeAndCycle(params, minimal, maximal, attribute) {
    let message
    // 校验“-”符号是否只有一个
    if (params.split('-').length > 2) {
        return (attribute + "中的参数只能有一个'-'")
    }
    let value = null
    let cycle = null
    // 检验范围内是否有嵌套周期
    if (params.indexOf('/') > -1) {
        // 校验“/”符号是否只有一个
        if (params.split('/').length > 2) {
            return (attribute + "中的参数只能有一个'/'")
        }
        value = params.split('/')[0]
        cycle = params.split('/')[1]
        // 判断循环的参数是否正确
        message = checkIntValue(cycle, minimal, maximal, true, attribute)
        if (message !== true) {
            return message
        }
    } else {
        value = params
    }
    let startValue = value.substring(0, value.indexOf('-'))
    let endValue = value.substring(value.indexOf('-') + 1)
    // 判断参数范围的第一个值是否正确
    message = checkIntValue(startValue, minimal, maximal, true, attribute)
    if (message !== true) {
        return message
    }
    // 判断参数范围的第二个值是否正确
    message = checkIntValue(endValue, minimal, maximal, true, attribute)
    if (message !== true) {
        return message
    }
    // 判断参数的范围前值是否小于后值
    try {
        let startVal = parseInt(startValue, 10)
        let endVal = parseInt(endValue, 10)
        if (endVal < startVal) {
            return (attribute + '的取值范围错误，前值必须小于后值')
        }
        if ((endVal - startVal) < parseInt(cycle, 10)) {
            return (attribute + '的取值范围内的循环无意义')
        }
        return true
    } catch (e) {
        // 用不到这行代码的
        return (attribute + '的参数有非法字符，必须是整数')
    }
}

// 检查日中的特殊字符
function checkFieldWithLetter(value, letter, minimalBefore, maximalBefore, attribute) {
    // 判断是否只有一个字母
    for (let i = 0; i < value.length; i++) {
        let count = 0
        if (value.charAt(i) === letter) {
            count++
        }
        if (count > 1) {
            return (attribute + '的值的' + letter + '字母只能有一个')
        }
    }
    // 校验L
    if (letter === 'L') {
        if (value === 'LW') {
            return true
        }
        if (value === 'L') {
            return true
        }
        if (value.endsWith('LW') && value.length > 2) {
            return (attribute + '中的参数，最后的LW前面不能有任何字母参数')
        }
        if (!value.endsWith('L')) {
            return (attribute + '中的参数，L字母后面不能有W以外的字符、数字等')
        } else {
            let num = value.substring(0, value.indexOf(letter))
            return checkIntValue(num, minimalBefore, maximalBefore, true, attribute)
        }
    }

    // 校验W
    if (letter === 'W') {
        if (!value.endsWith('W')) {
            return (attribute + '中的参数的W必须作为结尾')
        } else {
            if (value === 'W') {
                return (attribute + '中的参数的W前面必须有数字')
            }
            let num = value.substring(0, value.indexOf(letter))
            return checkIntValue(num, minimalBefore, maximalBefore, true, attribute)
        }
    }

    if (letter === 'C') {
        if (!value.endsWith('C')) {
            return (attribute + '中的参数的C必须作为结尾')
        } else {
            if (value === 'C') {
                return (attribute + '中的参数的C前面必须有数字')
            }
            let num = value.substring(0, value.indexOf(letter))
            return checkIntValue(num, minimalBefore, maximalBefore, true, attribute)
        }
    }
}

// 检查星期中的特殊字符
function checkFieldWithLetterWeek(value, letter, minimalBefore, maximalBefore, attribute) {
    let message
    // 判断是否只有一个字母
    for (let i = 0; i < value.length; i++) {
        let count = 0
        if (value.charAt(i) === letter) {
            count++
        }
        if (count > 1) {
            return (attribute + '的值的' + letter + '字母只能有一个')
        }
    }
    // 校验L
    if (letter === 'L') {
        if (value === 'L') {
            return true
        }
        if (!value.endsWith('L')) {
            return (attribute + '中的参数，L字母必须是最后一位')
        } else {
            let num = value.substring(0, value.indexOf(letter))
            return checkIntValue(num, minimalBefore, maximalBefore, true, attribute)
        }
    }

    if (letter === 'C') {
        if (!value.endsWith('C')) {
            return (attribute + '中的参数的C必须作为结尾')
        } else {
            if (value === 'C') {
                return (attribute + '中的参数的C前面必须有数字')
            }
            let num = value.substring(0, value.indexOf(letter))
            return checkIntValue(num, minimalBefore, maximalBefore, true, attribute)
        }
    }

    if (letter === '#') {
        if (value === '#') {
            return (attribute + '中的#前后必须有整数')
        }
        if (value.charAt(0) === letter) {
            return (attribute + '中的#前面必须有整数')
        }
        if (value.endsWith('#')) {
            return (attribute + '中的#后面必须有整数')
        }
        let num1 = value.substring(0, value.indexOf(letter))
        let num2 = value.substring(value.indexOf(letter) + 1, value.length)
        message = checkIntValue(num1, 1, 4, true, (attribute + '的#前面'))
        if (message !== true) {
            return message
        }
        message = checkIntValue(num2, minimalBefore, maximalBefore, true, (attribute + '的#后面'))
        if (message !== true) {
            return message
        }
        return true
    }
}

let stringCheck = {
    // 过滤合法的字符串
    filterIllegalString: function (str, option) {
        return new Promise((resolve, reject) => {
            let reg = ''
            if (option.number) {
                reg = reg + '0-9'
            }
            if (option.english) {
                reg = reg + 'a-zA-Z'
            }
            if (option.chinese) {
                reg = reg + '\u4e00-\u9fa5'
            }
            reg = `[^${reg}]`
            reg = new RegExp(reg, 'g')
            resolve(str.replace(reg, ''))
        })
    },
    // 截取规定字节长度的字符串
    checkByteLength: function (str, maxLength, errorCallback) {
        return new Promise((resolve, reject) => {
            let byteLength = 0
            let tempStr = ''
            for (let i = 0; i < str.length; i++) {
                let tempByteLength = (/[\u4e00-\u9fa5]/).test(str[i]) ? 2 : 1
                if (byteLength + tempByteLength > maxLength) {
                    errorCallback(`最多支持${maxLength}个字节`)
                    break
                }
                tempStr = tempStr + str[i]
                byteLength = byteLength + tempByteLength
            }
            resolve(tempStr)
        })
    },
    cutString: function (str, len) {
        //length属性读出来的汉字长度为1 
        if (str.length * 2 <= len) {
            return str
        }
        var strlen = 0
        var s = ''
        for (var i = 0; i < str.length; i++) {
            s = s + str.charAt(i)
            if (str.charCodeAt(i) > 128) {
                strlen = strlen + 2
                if (strlen >= len) {
                    return s.substring(0, s.length - 1) + '...'
                }
            } else {
                strlen = strlen + 1
                if (strlen >= len) {
                    return s.substring(0, s.length - 2) + '...'
                }
            }
        }
        return s
    },
    // toThousands: function (num) {
    //     return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
    // },
    toThousands: function (num) {
        var value = (num || 0).toString()
        var result = ''
        while (value.length > 3) {
            result = ',' + value.slice(-3) + result
            value = value.slice(0, value.length - 3)
        }
        if (value) { result = value + result }
        return result
    }
}

// 比较数组对象
function compareArrayObjects(object1, object2) {
    for (var propName in object1) {
        if (object1.hasOwnProperty(propName) !== object2.hasOwnProperty(propName)) {
            return false
        }
        else if (typeof object1[propName] !== typeof object2[propName]) {
            return false
        }
    }
    for (let propName in object2) {
        if (object1.hasOwnProperty(propName) !== object2.hasOwnProperty(propName)) {
            return false
        }
        else if (typeof object1[propName] !== typeof object2[propName]) {
            return false
        }
        if (!object1.hasOwnProperty(propName)) continue
        if (object1[propName] instanceof Array && object2[propName] instanceof Array) {
            if (!compareArrayObjects(object1[propName], object2[propName])) return false
        }
        else if (object1[propName] instanceof Object && object2[propName] instanceof Object) {
            if (!compareArrayObjects(object1[propName], object2[propName])) return false
        }
        else if (object1[propName] !== object2[propName]) {
            return false
        }
    }
    return true
}

// 支持限制输入32个中文字符或者64个英文字符 
function validInputlen(name, num) {
    let checklength = (str) => {
        var v_temp = str.replace(/^\s+/g, '').replace(/\s+$/g, '')
        if (v_temp.length != 0) str = v_temp
        // eslint-disable-next-line no-control-regex
        return str.replace(/[^\x00-\xff]/g, '**').length
    }
    let cutstr = (str, len) => {
        var str_length = 0
        var str_len = 0
        // eslint-disable-next-line no-new-wrappers
        var str_cut = new String()
        str_len = str.length
        for (var i = 0; i < str_len; i++) {
            var a = str.charAt(i)
            str_length++
            if (escape(a).length > 4) {
                //中文字符的长度经编码之后大于4  
                str_length++
            }
            str_cut = str_cut.concat(a)
            if (str_length >= len) {
                // str_cut = str_cut.concat("...")
                return str_cut
            }
        }
        //如果给定字符串小于指定长度，则返回源字符串；  
        if (str_length < len) {
            return str
        }
    }
    return cutstr(name, num)
    // if (checklength(name) > num) {
    //    return cutstr(name, num)
    // }
}

//函数节流和防抖
const throttle = function (fn, delay, isDebounce) {
    let timer
    let lastCall = 0
    return function (...args) {
        if (isDebounce) {
            if (timer) clearTimeout(timer)
            timer = setTimeout(() => {
                fn(...args)
            }, delay)
        } else {
            const now = new Date().getTime()
            if (now - lastCall < delay) return
            lastCall = now
            fn(...args)
        }
    }
}

function getDate() {
    var time = new Date()
    var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    return y + '/' + m + '/' + d
}

function getSecond() {
    var time = new Date()
    // var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    if (h.toString().length < 2) {
        h = '0' + h
    }
    if (s.toString().length < 2) {
        s = '0' + s
    }
    if (ss.toString().length < 2) {
        ss = '0' + ss
    }
    // return y + '-' + m + '-' + d + ' ' + h + ':' + s + ':' + ss
    // return h + ':' + s + ':' + ss
    return h + ':' + s
}

function getWeek() {
    var arr = ['日', '一', '二', '三', '四', '五', '六', '日']
    var week = new Date().getDay()
    return '星期' + arr[week]
}
function getTime(tm) {
    if (!tm) {
        return ''
    }
    tm = typeof tm === 'string' && !isNaN(tm - 0) ? tm - 0 : tm
    var time = new Date(tm)
    var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    if (h.toString().length < 2) {
        h = '0' + h
    }
    if (s.toString().length < 2) {
        s = '0' + s
    }
    if (ss.toString().length < 2) {
        ss = '0' + ss
    }
    return y + '/' + m + '/' + d + ' ' + h + ':' + s + ':' + ss
}
function getStrTime(tm) {
    var time = new Date(tm)
    var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    if (h.toString().length < 2) {
        h = '0' + h
    }
    if (s.toString().length < 2) {
        s = '0' + s
    }
    if (ss.toString().length < 2) {
        ss = '0' + ss
    }
    return y + '-' + m + '-' + d + ' ' + h + ':' + s + ':' + ss
}

function getCurrentTime() {
    var time = new Date()
    var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    if (h.toString().length < 2) {
        h = '0' + h
    }
    if (s.toString().length < 2) {
        s = '0' + s
    }
    if (ss.toString().length < 2) {
        ss = '0' + ss
    }
    return y + '-' + m + '-' + d + ' ' + h + ':' + s + ':' + ss
}
function getPrevTime() {
    var time = new Date()
    var y = time.getFullYear()
    var m = time.getMonth()
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    if (m.toString().length < 2) {
        m = '0' + m
    }
    if (d.toString().length < 2) {
        d = '0' + d
    }
    if (h.toString().length < 2) {
        h = '0' + h
    }
    if (s.toString().length < 2) {
        s = '0' + s
    }
    if (ss.toString().length < 2) {
        ss = '0' + ss
    }
    return y + '-' + m + '-' + d + ' ' + h + ':' + s + ':' + ss
}

function getMonths(tm) {
    var time = new Date(tm)
    var y = time.getFullYear()
    var m = time.getMonth() + 1
    var d = time.getDate()
    var h = time.getHours()
    var s = time.getMinutes()
    var ss = time.getSeconds()
    // if (m.toString().length < 2) {
    //     m = '0' + m
    // }
    // if (d.toString().length < 2) {
    //     d = '0' + d
    // }
    // if (h.toString().length < 2) {
    //     h = '0' + h
    // }
    // if (s.toString().length < 2) {
    //     s = '0' + s
    // }
    // if (ss.toString().length < 2) {
    //     ss = '0' + ss
    // }
    return m + '月' + d + '日'
}

const closeFunc = (fun) => {
    var _beforeUnload_time = 0
    var _gap_time = 0
    var is_fireFox = navigator.userAgent.indexOf('Firefox') > -1
    window.onunload = () => {
        _gap_time = new Date().getTime() - _beforeUnload_time
        if (_gap_time <= 5) {
            // 关闭
            fun()
        } else {
            // 刷新
        }
        document.cookie = 'aaa=' + _gap_time
    }
    window.onbeforeunload = () => {
        _beforeUnload_time = new Date().getTime()
        if (is_fireFox) {
            // 火狐关闭
            fun()
        }
    }
}

export default {
    formatDateFromLong,
    generateUUID,
    cronValidate,
    stringCheck,
    compareArrayObjects,
    validInputlen,
    getDate,
    getSecond,
    getWeek,
    getTime,
    getMonths,
    getCurrentTime,
    getPrevTime,
    getStrTime,
    throttle,
    closeFunc
}
